<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<!-- header -->
		<%@ include file="/WEB-INF/views/include/header.jsp"%>
		<link rel="stylesheet" href="<s:url value="/ueditor/themes/default/css/ueditor.css"></s:url>" />
		<link rel="stylesheet" href="<s:url value="/ueditor/themes/default/css/ueditor.css"></s:url>" />
		<link rel="stylesheet" href="<s:url value="/assets/css/bootstrap-datetimepicker.min.css"></s:url>" />
		<style>
			.no-padding-right{
				color:#fff;
			}
			.page-content label{
				color:#ffffff;
			}
		</style>
	</head>
	<body class="no-skin">
		<!-- /section:basics/navbar.layout -->
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div class="main-content-inner">
					<div class="page-content">
						<form:form commandName="ResourceNewsFilter" cssClass="form-horizontal" id="articleFrom" role="form">
						
							<%--<div class="form-group">--%>
								<%--<label class="col-sm-2 control-label no-padding-right" for="title">标题<font color="red">*</font></label>--%>
								<%--<div class="col-sm-3">--%>
									<%--<input type="text" name="title" id="title" placeholder="请输入标题"  class="form-control required">--%>
								<%--</div>--%>
								<%----%>
								<%--<label class="col-sm-2 control-label no-padding-right" for="subheading">副标题<font color="red">*</font></label>--%>
								<%--<div class="col-sm-3">--%>
									<%--<input type="text" name="subheading" id="subheading" placeholder="请输入副标题" value="${ResourceNewsFilter.subheading}" class="form-control required">--%>
								<%--</div>--%>
							<%--</div>--%>
							<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right" for=type>类型<font color="red">*</font></label>
							<div class="col-sm-3">
								<select name="type" id="type" class="form-control " onchange="getSubjectTypeId2()">
									<option value="全县情况">全县情况</option>
									<option value="招商工作动态">招商工作动态</option>
									<option value="对外推荐资源">对外推荐资源</option>
									<option value="政策法规">政策法规</option>
									<option value="产业链">产业链</option>

								</select>
							</div>
								<label class="col-sm-2 control-label no-padding-right" for="title">标题</label>
								<div class="col-sm-3">
									<input type="text" name="title" id="title" placeholder="请输入标题" value="${ResourceNewsFilter.title}" class="form-control">
								</div>
							</div>
							
							<input type="hidden" name="content" id="content" value="${ResourceNewsFilter.content}">
							<%--<input type="hidden" name="subheading" id="subheading" value="${hstPaperEssayQuestion.subheading }">--%>
							<%--<input type="hidden" name="requirement" id="requirement" value="${hstPaperEssayQuestion.requirement }">--%>
							<%--<input type="hidden" name="referenceAnswer" id="referenceAnswer" value="${hstPaperEssayQuestion.requirement }">--%>
							<%--<input type="hidden" name="analysis" id="analysis" value="${hstPaperEssayQuestion.requirement }">--%>
							<%----%>
							<%--<input type="hidden" name="sysId" id="sysId" value="${hstPaperEssayQuestion.sysId }">--%>
							<%--<input type="hidden" name="productCode" id="productCode" value="shenlun"> <!-- 产品代号 -->--%>
						</form:form>
						<form class="form-horizontal" role="form" id="contentForm" >
							
							<%--<div class="form-group">--%>
								<%--<label class="col-sm-2 control-label no-padding-right" for="title">题目<font color="red">*</font></label>--%>
								<%--<div class="col-sm-8">--%>
									<%--<textarea rows="3" id="_title" name="title" style="width: 100%" required></textarea>--%>
								<%--</div>--%>
							<%--</div>--%>


							<%--<div class="form-group">--%>
								<%--<label class="col-sm-2 control-label no-padding-right" for="questionSource">来源</label>--%>
								<%--<div class="col-sm-8">--%>
									<%--<textarea rows="1" id="questionSource" name="questionSource" disabled="disabled" style="width: 100%"></textarea>--%>
								<%--</div>--%>
							<%--</div>--%>



							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right" for="content">内容<font color="red">*</font></label>
								<div class="col-sm-8">
									<textarea rows="3" id="_content" name="content" style="width: 100%">${ResourceNewsFilter.content}</textarea>
								</div>
							</div>

							<%--<div class="form-group">--%>
								<%--<label class="col-sm-2 control-label no-padding-right" for="analysis">详细解析</label>--%>
								<%--<div class="col-sm-8">--%>
									<%--<textarea rows="3" id="_analysis" name="analysis"  style="width: 100%">${hstPaperEssayQuestion.analysis }</textarea>--%>
								<%--</div>--%>
							<%--</div>--%>
							
						</form>
						<h3 class="header smaller lighter green"></h3>
					    <div class="text-center">
							<button class="btn btn-info" id="edit">提交</button>
							<button class="btn btn-pink" id="reset">重置</button>
							<button class="btn btn-default" id="close">关闭</button>
						</div>
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
			</a>
			
			<!-- dialog -->
			<%@ include file="/WEB-INF/views/include/dialog.jsp"%>
		</div><!-- /.main-container -->
		<!-- footer -->
		<%@ include file="/WEB-INF/views/include/footer.jsp"%>
		<script type="text/plain" id="upload_ue"></script>
		<script type="text/javascript"  src="<s:url value="/assets/js/date-time/js/bootstrap-datetimepicker.js"></s:url>"></script>
		<script type="text/javascript"  src="<s:url value="/assets/js/date-time/js/locales/bootstrap-datetimepicker.zh-CN.js"></s:url>"></script>
		<script type="text/javascript"  src="<s:url value="/ueditor/ueditor.config.js"></s:url>"></script>
		<script type="text/javascript"  src="<s:url value="/ueditor/ueditor.all.min.js"></s:url>" ></script>
		<script type="text/javascript">

            var baseUrl = "<s:url value="/resourceNews/create"></s:url>/"
			
//		 	var ue_title = UE.getEditor('_title', {
//				initialFrameHeight:100,
//				autoHeightEnabled:true
//			});
			
			var ue_content = UE.getEditor('_content', {
				initialFrameHeight:100,
				autoHeightEnabled:true
			}); 
			
			
//			var ue_analysis = UE.getEditor('_analysis', {
//				initialFrameHeight:100,
//				autoHeightEnabled:true
//			});
			
			//上传独立使用
			var _editor = UE.getEditor('upload_ue');
			_editor.ready(function() {
				_editor.setDisabled();
				_editor.hide();
				_editor.addListener('beforeInsertImage', function(t, arg) { //侦听图片上传
					//将地址赋值给相应的input
					$("#littleImg").attr("value", arg[0].src);
					//图片预览
					$("#preview").attr("src", arg[0].src);
				})
				_editor.addListener('afterUpfile', function(t, arg) {
					$("#file").attr("value", arg[0].url);
				})
			});
			
			function upImage() {
				var myImage = _editor.getDialog("insertimage");
				myImage.open();
			}
			
			$("#edit").click(function() {
				
//				$("#title").val(ue_title.getContent());
				// $("#subheading").val($("#_subheading").val());
//				$("#requirement").val($("#_requirement").val());
				$("#content").val(ue_content.getContent());
//				$("#analysis").val(ue_analysis.getContent());
				
				var url ="<s:url value="/resourceNews/create"></s:url>";
				<%--if(${!empty hstPaperEssayQuestion.sysId }){--%>
					<%--url ="<s:url value="/modules/paper/essayQuestion/edit"></s:url>";--%>
				<%--}else{--%>
					<%--url ="<s:url value="/modules/paper/essayQuestion/create"></s:url>";--%>
				<%--}--%>
				if($("#articleFrom").valid()) {
					postCallBack({
						data:serialize("#articleFrom"),
						url:url,
						successMessage:"提交成功",
						successFunc:function(data){
							if(data.code=="200"){
								/* $(window.parent.document).contents().find("#appiframe-ATM01")[0].contentWindow.query(); */
								//更新数据的代码实现
								top.frames["appiframe-eQuestion"].reload("#gridTable");//重载
								setTimeout(function(){	
									var appid = "EssayQuestion";
									window.parent.closeapp($("#task-content li[app-id='"+ appid +"']",parent.document));
								},1000); 
							}
						}
					});	
				}
			});
			
			
			$("#reset").click(function() {
				//重置表单
				$('#contentForm')[0].reset();
				$('#articleFrom')[0].reset();
			});
			
			$("#close").click(function(){
				var appid = "EssayQuestion";
				window.parent.closeapp($("#task-content li[app-id='" + appid+ "']", parent.document));
			});
			
			$(".form_datetime").datetimepicker({
				format: 'yyyy-mm-dd hh:ii:ss',
				language:'zh-CN',
			    autoclose: true,
		        todayBtn: true
			});

            function getSubjectTypeId2() {
                var subjectId=$("#subjectTypeId").find('option:selected').val();
                $("#subjectTypeId2").empty();     //清空二级目录
                var classNext=$("#subjectTypeId2");
                $.ajax({
                    dataType: "json",
                    type: 'GET',
                    url:"/modules/paper/wholePaper/getSubjectTypeId2?subjectId="+subjectId,
                    success: function (result) {
                        var  data = result.data;
                        if(data.length!="" && data.length!=null){
                            for ( var i = 0; i < data.length; i++) {
                                classNext.append("<option value="+data[i].sysId+">"+data[i].columnName+"</option>");
                            }
                        }else{
                            $("#tab1_subjectTypeId2").empty();     //清空二级目录
                            classNext.append("<option value="+subjectId2+">---无---</option>");
                        }
                    }

                })
			     console.log($("#type").val(),1111);
                //  显示隐藏事件
				var val = $("#type").val();
				var vals = val == "全县情况" || val == "招商工作动态" || val == "对外推荐资源" || val == "政策法规" || val == "产业链" ;
				if(vals){
					$("#jwd").hide();
                    $("#radius").hide();
                    $("#names").hide();
				}else {
                    $("#jwd").show();
                    $("#radius").show();
                    $("#names").show();
				}

            }




		</script>
	</body>
</html>